package com.lineage.server.serverpackets;

import com.lineage.server.datatables.lock.AuctionBoardReading;
import com.lineage.server.templates.L1AuctionBoardTmp;

public class S_ApplyAuction extends ServerBasePacket {
  private byte[] _byte;
  
  public S_ApplyAuction(int objectId, String houseNumber) {
    this._byte = null;
    buildPacket(objectId, houseNumber);
  }
  
  private void buildPacket(int objectId, String houseNumber) {
    int number = Integer.valueOf(houseNumber).intValue();
    L1AuctionBoardTmp board = AuctionBoardReading.get().getAuctionBoardTable(number);
    writeC(136);
    writeD(objectId);
    writeD(0);
    if (board.getBidderId() == 0) {
      writeD((int)board.getPrice());
      writeD((int)board.getPrice());
    } else {
      writeD((int)board.getPrice() + 1);
      writeD((int)board.getPrice() + 1);
    } 
    writeD(2000000000);
    writeH(0);
    writeS("agapply");
    writeS("agapply " + houseNumber);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
